<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head id="MyHead">
<script src="../resources/Scripts/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="../resources/Scripts/jquery.easyui.min-1.3.5.js" type="text/javascript"></script>
<script src="../resources/Scripts/jquery.datagrid.js" type="text/javascript"></script>
<script src="../resources/Scripts/JScriptIndex.js" type="text/javascript"></script>
<!-- <link href="../resources/Content/Default.css" rel="stylesheet" type="text/css" /> -->
<link href="../resources/Content/IndexStyle.css" rel="stylesheet" type="text/css" />
<link href="../resources/Res/easyui/themes/icon.css" rel="stylesheet" type="text/css" />
<script src="../resources/Res/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<link href="../resources/Res/easyui/themes/default/easyui.css" rel="stylesheet" type="text/css" />
<title>C_Car</title>
<script type="text/javascript" language="javascript">
	$(function() {
		$
				.extend(
						$.fn.datagrid.methods,
						{
							addToolbarItem : function(jq, items) {
								return jq
										.each(function() {
											var dpanel = $(this).datagrid(
													'getPanel');
											var toolbar = dpanel
													.children("div.datagrid-toolbar");
											if (!toolbar.length) {
												toolbar = $(
														"<div class=\"datagrid-toolbar\"><table cellspacing=\"0\" cellpadding=\"0\"><tr></tr></table></div>")
														.prependTo(dpanel);
												$(this).datagrid('resize');
											}
											var tr = toolbar.find("tr");
											for (var i = 0; i < items.length; i++) {
												var btn = items[i];
												if (btn == "-") {
													$(
															"<td><div class=\"datagrid-btn-separator\"></div></td>")
															.appendTo(tr);
												} else {
													var td = $("<td></td>")
															.appendTo(tr);
													var b = $(
															"<a href=\"javascript:void(0)\"></a>")
															.appendTo(td);
													b[0].onclick = eval(btn.handler
															|| function() {
															});
													b.linkbutton($.extend({},
															btn, {
																plain : true
															}));
												}
											}
										});
							},
							removeToolbarItem : function(jq, param) {
								return jq
										.each(function() {
											var dpanel = $(this).datagrid(
													'getPanel');
											var toolbar = dpanel
													.children("div.datagrid-toolbar");
											var cbtn = null;
											if (typeof param == "number") {
												cbtn = toolbar.find("td").eq(
														param).find(
														'span.l-btn-text');
											} else if (typeof param == "string") {
												cbtn = toolbar
														.find("span.l-btn-text:contains('"
																+ param + "')");
											}
											if (cbtn && cbtn.length > 0) {
												cbtn.closest('td').remove();
												cbtn = null;
											}
										});
							}
						});
	});
</script>


<script type="text/javascript" language="javascript">
	//“导出EXCEL”按钮     在6.0版本中修改
	$(function() {

		var currTab = window.top.$('#tabs').tabs('getSelected'); //获得当前tab
		var iframeid = $(currTab.panel('options').content).attr('id');

		//关闭AJAX相应的缓存
		$.ajaxSetup({
			cache : false
		});

		$.post("../resources/Home/GetToolbar", {
			id : iframeid
		}, function(data) {
			if (data == null) {
				return;
			}
			//alert(data);
			//$('#toolbar').html(data);
			$('#flexigridData').datagrid("addToolbarItem", data);
		});

		$('#flexigridData').datagrid({
			//title: '车辆信息管理', //列表的标题
			iconCls : 'icon-site',
			width : 'auto',
			height : 'auto',
			nowrap : true,
			striped : true,
			collapsible : true,
			url : '/carInfoList', //获取数据的url
			sortName : 'ciId',
			sortOrder : 'desc',
			idField : 'ciId',

			toolbar : [ {
				text : '查询',
				iconCls : 'icon-search',
				handler : function() {
					flexiQuery();
				}
			}, 
				{
				text : '查看',
				iconCls : 'icon-search',
				handler : function() {
					getView();
				}
			}, 
				{
				text : '创建',
				iconCls : 'icon-add',
				handler : function() {
					return flexiCreate();
				}
			}, {
				text : '修改',
				iconCls : 'icon-edit',
				handler : function() {
					return flexiModify();
				}
			} 
			, {
				text : '删除',
				iconCls : 'icon-remove',
				handler : function() {
					return flexiDelete();
				}
			} 		
			],
			columns : [ [
			             {field:'ciId',title:'数据',width:150,hidden:'true'},

			{
				field : 'ciPlatenumber',
				title : '<label for="ciPlatenumber">车牌号</label>',
				width : 80
			}, {
				field : 'ciDriver',
				title : '<label for="ciDriver">司机</label>',
				width : 80
			}, {
				field : 'ciUnitprice',
				title : '<label for="ciUnitprice">练车单价</label>（元/分钟）',
				width : 80
			}, {
				field : 'ciBranchschool',
				title : '<label for="ciBranchschool">所在分校</label>',
				width : 120
			}, {
				field : 'ciSitenumber',
				title : '<label for="ciSitenumber">场地编号</label>',
				width : 80
			}, {
				field : 'ctType',
				title : '<label for="ctType">车型代码</label>',
				width : 80
			}, {
				field : 'ciMotorcade',
				title : '<label for="ciMotorcade">所属车队</label>',
				width : 80
			}, {
				field : 'ciOwner',
				title : '<label for="ciOwner">车主</label>',
				width : 80
			}, {
				field : 'ciFrameno',
				title : '<label for="ciFrameno">车架号</label>',
				width : 80
			}, {
				field : 'ciAddress',
				title : '<label for="ciAddress">地址</label>',
				width : 80
			}, {
				field : 'ciEngine',
				title : '<label for="ciEngine">发动机号</label>',
				width : 80
			}, {
				field : 'ciFactoryplatemodel',
				title : '<label for="ciFactoryplatemodel">厂牌型号</label>',
				width : 80
			}, {
				field : 'ciRecorddate',
				title : '<label for="ciRecorddate">登记日期</label>',
				width : 80,
				formatter: function (value, rec) {
			     if (value) {
			         return dateConvert1(value);
			     } 
			 } 
			}, {
				field : 'ciAnnualcheckEndtime',
				title : '<label for="ciAnnualcheckEndtime">年审截止日期</label>',
				width : 100
			 , formatter: function (value, rec) {
			    if (value) {
			        return dateConvert1(value);
			    }
			} 
			}, {
				field : 'ciWarrantyEndtime',
				title : '<label for="ciWarrantyEndtime">保修截止日期</label>',
				width : 100 , 
				 formatter: function (value, rec) {
			    if (value) {
			        return dateConvert1(value);
			    }
			} 
			}, {
				field : 'ciCompletemaintenance',
				title : '<label for="ciCompletemaintenance">二级维护截止日期</label>',
				width : 100, 
				formatter: function (value, rec) {
			      if (value) {
			          return dateConvert1(value);
			      }
			  }
			}, {
				field : 'ciMarketingunit',
				title : '<label for="ciMarketingunit">销售单位</label>',
				width : 80
			}, {
				field : 'ciCertificatetime',
				title : '<label for="ciCertificatetime">发证日期</label>',
				width : 80,
				formatter: function (value, rec) {
				      if (value) {
				          return dateConvert1(value);
				      }
				  }
				
			}, {
				field : 'ciInitmileage',
				title : '<label for="ciInitmileage">初始里程</label>',
				width : 80
			}, {
				field : 'ciColor',
				title : '<label for="ciColor">车颜色</label>',
				width : 80
			}, {
				field : 'ciBreakrolesEvent',
				title : '<label for="ciBreakrolesEvent">车辆历史违章及事故</label>',
				width : 80
			}	
			, {
				field : 'ciCheckstatus',
				title : '<label for="ciCheckstatus">审核状态</label>',
				width : 80
			}, {
				field : 'ciIdentityid',
				title : '<label for="ciIdentityid">身份证号(驾驶员)</label>',
				width : 80
			}, {
				field : 'ciTelephonenumber',
				title : '<label for="ciTelephonenumber">联系电话(驾驶员)</label>',
				width : 80
			}
			, {
				field : 'ciMemo',
				title : '<label for="ciMemo">备注</label>',
				width : 80
			}, {
				field : 'ciRecorder',
				title : '<label for="ciRecorder">录入人</label>',
				width : 80
			}, {
				field : 'ciRecordtime',
				title : '<label for="ciRecordtime">录入时间</label>',
				width : 80
		  , formatter: function (value, rec) {
			     if (value) {
			         return dateConvert1(value);
			     } 
			 }  
			} ] ],
			pagination : true,
			rownumbers : true

		});
	});

	//“查询”按钮，弹出查询框
	function flexiQuery() {
		$('#divQuery')
				.dialog(
						{
							buttons : [
									{
										text : '查询',
										iconCls : 'icon-ok',
										handler : function() {
											//执行查询                        
											$('#flexigridData').datagrid(
													'reload', {
														//车牌号
														C_no : $('#C_no').val(),
														//车牌小号
														C_sno:$('#C_sno').val(),
														//场地编号
														C_Pno : $('#C_Pno').val(),
														//车型
														C_typeDDL_String : $('#C_typeDDL_String').val(),
														//车主
														C_master : $('#C_master').val(),
														//档案编号
														C_filesNo : $('#C_filesNo').val(),
														//司机
														C_dirver : $('#C_dirver').val(),
														//驾驶员身份证号
														C_GPSNO : $('#C_GPSNO').val(),
														
														
													});
										}
									}, {
										text : '取消',
										iconCls : 'icon-cancel',
										handler : function() {
											$('#divQuery').dialog("close");
										}
									} ]
						});
		$('#divQuery').dialog("open");
	};

	//“选择”按钮，在其他（与此页面有关联）的页面中，此页面以弹出框的形式出现，选择页面中的数据
	function flexiSelect() {

		var rows = $('#flexigridData').datagrid('getSelections');
		if (rows.length == 0) {
			$.messager.alert('操作提示', '请选择数据!', 'warning');
			return false;
		}

		var arr = [];
		for (var i = 0; i < rows.length; i++) {
			arr.push(rows[i].ci_id);
		}
		arr.push("^");
		for (var i = 0; i < rows.length; i++) {
			arr.push(rows[i].C_no);
		}
		//主键列和显示列之间用 ^ 分割   每一项用 , 分割
		if (arr.length > 0) {//一条数据和多于一条
			returnParent(arr.join("&")); //每一项用 & 分割
		}
	}
	//导航到查看详细的按钮
	function getView() {

		var arr = $('#flexigridData').datagrid('getSelections');
		
		alert(arr[0].ciId); 
		if (arr.length == 1) {
	
			// window.location.href = "CarInfoByCid/" + arr[0].ciId; 
			 parent.addTab("车辆:" + arr[0].C_no, "/CarInfoByCid/"
					+ arr[0].ciId, "tu1001", true); 
					 
					 
		} else {
			
			$.messager.alert('操作提示', '请选择一条数据!', 'warning');
		}
		return false;

	}

	
	//导航到创建的按钮
	function flexiCreate() {

		//window.location.href = "../resources/C_Car/Create";
		parent.addTab("新增车辆", "/goaddCarInfo", "tu1001", true);
		
		return false;
	}
	//导航到修改的按钮
	function flexiModify() {

		var arr = $('#flexigridData').datagrid('getSelections');

		if (arr.length == 1) {
			parent.addTab("修改车辆:" + arr[0].C_no, "/updateCarInfo/"
					+ arr[0].ciId, "tu1001", true);

		} else {
			$.messager.alert('操作提示', '请选择一条数据!', 'warning');
		}
		return false;

	};
	//删除的按钮
	function flexiDelete() {

		var rows = $('#flexigridData').datagrid('getSelections');
		
		if (rows.length == 0) {
			$.messager.alert('操作提示', '请选择数据!', 'warning'); 
			return false;
		}

		var arr = [];
		for (var i = 0; i < rows.length; i++) {
			arr.push(rows[i].ciId);
		}

		$.messager.confirm('操作提示', "确认删除这 " + arr.length + " 项吗？", function(r) {
			if (r) {
				$.post("/delCarInfo", {
					query : arr.join(",")
				}, function(res) {
					if (res == "OK") {
						//移除删除的数据
						$.messager.alert('操作提示', '删除成功!', 'info');
						$("#flexigridData").datagrid("reload");
						$("#flexigridData").datagrid("clearSelections");
					} else {
						if (res == "") {
							$.messager.alert('操作提示',
									'删除失败!请查看该数据与其他模块下的信息的关联，或联系管理员。', 'info');
						} else {
							$.messager.alert('操作提示', res, 'info');
						}
					}
				});
			}
		});

	};
</script>

<script src="../resources/Res/My97DatePicker/WdatePicker.js"
	type="text/javascript"></script>

<base target="_self">
</head>
<body class="easyui-layout" style="padding: 3px;">
	<table id="flexigridData" fit="true">
	</table>

	<div id="divQuery" title="查询列表" class="easyui-dialog" closed="true"
		modal="false" iconcls="icon-search">

		<div class="input">
			<div class="editor-label-search">
				<label for="C_no">车牌号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_no' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_sno">车牌小号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_sno' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_Pno">场地编号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_Pno' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_type">车型代码</label>
			</div>
			<div class="editor-field-search">
				<select id="C_typeDDL_String" name="C_typeDDL_String"><option
						value="">请选择</option>
					<option value="A">A</option>
					<option value="B">B</option>
					<option value="C">C</option>
				</select>
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_master">车主</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_master' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_filesNo">档案编号</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_filesNo' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_dirver">司机</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_dirver' />
			</div>
		</div>
		<div class="input">
			<div class="editor-label-search">
				<label for="C_GPSNO">身份证号(驾驶员)</label>
			</div>
			<div class="editor-field-search">
				<input type='text' id='C_GPSNO' />
			</div>
		</div>
		<!-- <div class="input">
			<div class="editor-label-search">
				<label for="C_regdate">登记日期</label>
			</div>
			<div class="editor-field-search" style="width: 360px;">
				<input type='text' id='C_regdateStart_Time'
					onclick="WdatePicker({maxDate:'#F{$dp.$D(\'C_regdateStart_Time\');}'})" />
				到 <input type='text' id='C_regdateEnd_Time'
					onclick="WdatePicker({minDate:'#F{$dp.$D(\'C_regdateEnd_Time\');}'})" />
			</div>
		</div> -->
	</div>


</body>
</html>